package com.hebeu.group.service.impl;

import com.hebeu.group.mapper.UserMapper;
import com.hebeu.group.pojo.User;
import com.hebeu.group.pojo.UserExample;
import com.hebeu.group.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    private UserMapper userMapper;

    @Autowired
    public UserServiceImpl(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    @Override
    public List<User> selectUser(String username, String password) {
        UserExample userExample = new UserExample();
        UserExample.Criteria criteria = userExample.createCriteria();
        criteria.andUserNameEqualTo(username);
        criteria.andUserPasswordEqualTo(password);
        return userMapper.selectByExample(userExample);
    }


    @Override
    public User findUserById(int user_id) {
        userMapper.selectByPrimaryKey(user_id);
        return null;
    }

    @Override
    public void updateUser(User user) {
        userMapper.updateByPrimaryKeySelective(user);
    }

    @Override
    public void insertUser(User user) {
        userMapper.insertSelective(user);
    }
}
